package cn.dujc.superkid.utils;

import android.view.View;

public abstract class OnMultiClickListener implements View.OnClickListener{
  /**
   *    两次点击按钮之间的点击间隔不能少于3000毫秒
   *    调用方法：
   *        btn.setOnClickListener(new OnMultiClickListener() {
   /*            @Override
   *             public void onMultiClick(View v) {
   *                //点击事件
   *            }
   *        });
   * **/
    private static final int MIN_CLICK_DELAY_TIME = 3000;
    private static long lastClickTime;

    public abstract void onMultiClick(View v);

    @Override
    public void onClick(View v) {
        long curClickTime = System.currentTimeMillis();
        if((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
            // 超过点击间隔后再将lastClickTime重置为当前点击时间
            lastClickTime = curClickTime;
            onMultiClick(v);
        }
    }
}